package com.dxf.bigdata.D04_spark

import org.apache.commons.logging.{Log, LogFactory}
import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 *  行动算子 :如  collect()
 *
 *    触发作业执行的方法
 *
 *    =========================
 *
 *    collect
 *      将不同分区的数据按照分区顺序采集到Driver端内存中,形成数组
 *
 *
 *
 */
object T32_RDD行动算子_collect {
  private val log: Log = LogFactory.getLog(T08_RDD使用_从日志中读取uri.getClass)

  def main(args: Array[String]): Unit = {

    //TODO 准备环境
    val sparkConf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("RDD")
    val sc = new SparkContext(sparkConf)

    //TODO 创建RDD 案例实操
    val rdd: RDD[Int] = sc.makeRDD(List(1, 2, 3, 4))

    val int: Int = rdd.reduce(_ + _)
    println(int)



    //TODO 关闭环境
    sc.stop()


  }
}
